package com.iweb.xt.web.controller;

import com.iweb.xt.common.cache.Cache;
import com.iweb.xt.common.model.CallResult;
import com.iweb.xt.web.model.NewsParam;
import com.iweb.xt.web.service.NewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("news")
public class NewController {
    @Autowired
    private NewService newService;
    @PostMapping("newList")
    @Cache(time = 2*60*1000,name = "News")
    public CallResult newList(@RequestBody NewsParam newsParam){
        return newService.newList(newsParam);
    }
    @PostMapping("detail")
    @Cache(time = 30*1000,name = "News")
    public CallResult news(@RequestBody NewsParam newsParam){
        return newService.findNewsById(newsParam);
    }
    @PostMapping("newsDetailList")
    @Cache(time = 30*1000,name = "News")
    public CallResult newsDetailList(@RequestBody NewsParam newsParam){
        return newService.newsDetailList(newsParam);
    }
}
